package com.ktgj.customer.controller;

import java.util.List;
import java.io.IOException;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.customer.domain.CustomerCardRecord;
import com.ktgj.customer.service.ICustomerCardRecordService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 会员购卡未执行记录Controller
 * 
 * @author ruoyi
 * @date 2022-07-14
 */
@RestController
@RequestMapping("/customerCardRecord")
public class CustomerCardRecordController extends BaseController
{
    @Autowired
    private ICustomerCardRecordService customerCardRecordService;

    /**
     * 查询会员购卡未执行记录列表
     */
    @PreAuthorize(hasPermi = "system:record:list")
    @GetMapping("/list")
    public TableDataInfo list(CustomerCardRecord customerCardRecord)
    {
        startPage();
        List<CustomerCardRecord> list = customerCardRecordService.selectCustomerCardRecordList(customerCardRecord);
        return getDataTable(list);
    }

    /**
     * 导出会员购卡未执行记录列表
     */
    @PreAuthorize(hasPermi = "system:record:export")
    @Log(title = "会员购卡未执行记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CustomerCardRecord customerCardRecord) throws IOException
    {
        List<CustomerCardRecord> list = customerCardRecordService.selectCustomerCardRecordList(customerCardRecord);
        ExcelUtil<CustomerCardRecord> util = new ExcelUtil<CustomerCardRecord>(CustomerCardRecord.class);
        util.exportExcel(response, list, "会员购卡未执行记录数据");
    }

    /**
     * 获取会员购卡未执行记录详细信息
     */
    @PreAuthorize(hasPermi = "system:record:query")
    @GetMapping(value = "/{recordId}")
    public AjaxResult getInfo(@PathVariable("recordId") Long recordId)
    {
        return AjaxResult.success(customerCardRecordService.selectCustomerCardRecordById(recordId));
    }

    /**
     * 新增会员购卡未执行记录
     */
    @PreAuthorize(hasPermi = "system:record:add")
    @Log(title = "会员购卡未执行记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CustomerCardRecord customerCardRecord)
    {
        return toAjax(customerCardRecordService.insertCustomerCardRecord(customerCardRecord));
    }

    /**
     * 修改会员购卡未执行记录
     */
    @PreAuthorize(hasPermi = "system:record:edit")
    @Log(title = "会员购卡未执行记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CustomerCardRecord customerCardRecord)
    {
        return toAjax(customerCardRecordService.updateCustomerCardRecord(customerCardRecord));
    }

    /**
     * 删除会员购卡未执行记录
     */
    @PreAuthorize(hasPermi = "system:record:remove")
    @Log(title = "会员购卡未执行记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordIds}")
    public AjaxResult remove(@PathVariable Long[] recordIds)
    {
        return toAjax(customerCardRecordService.deleteCustomerCardRecordByIds(recordIds));
    }

    /**
     * 未执行记录信息列表
     * */
    @PostMapping("/customerCardRecordList")
    public AjaxResult customerCardRecordList(@RequestBody Map<String, Object> map){
        Long id = Long.valueOf(map.get("id").toString());
        List<CustomerCardRecord> customerCardRecords = customerCardRecordService.customerCardRecordList(id);
        return AjaxResult.success(customerCardRecords);
    }
}
